"use strict";
/**
 * @author 太阳当空丶赵
 * @date 2022/10/22-14:30
 * @version 1.0.0
 */
const path = require("path")
const multer = require("multer")

//文件存储中间件
const storage = multer.diskStorage({
    // destination:'public/uploads/'+new Date().getFullYear() + (new Date().getMonth()+1) + new Date().getDate(),
    destination(req, res, cb) {
        cb(null, path.join(__dirname, "../tempFile"), new Date().getDate());
    },
    filename(req, file, cb) {
        const fileType = file.mimetype.split("/")[1]
        // const filenameArr = file.originAlname.split('.');
        // console.log(filenameArr)
        // cb(null, Date.now() + '.' + filenameArr[filenameArr.length - 1]);
        cb(null, Date.now() + '.' + fileType);
    }
})

module.exports = multer({storage})
